<!--终端-->
<template>
    <div class="current-page">
        <div class="titleList">
            <el-row>
                <el-col :span="5" :offset="19">
                    <el-button type="primary" @click="increase('add')">增加</el-button>
                    <el-button type="primary" @click="addDelet" style="margin-left:20px;">删除</el-button>
                    <el-button type="primary" @click="increase" style="margin-left:20px;">修改</el-button>
                    <el-button type="primary" style="margin-left:20px;">生效</el-button>
                </el-col>
            </el-row>
            <div class="btn-right">
            </div>
        </div>
        <com-table ref="comTable" :tableData="tableData" url="system/log/local" keyName="XPRO_ARRAY" :has-data="hasData"
            :table-head-list="tableHeadList" :total-count="totalCount" :page-num="pageNum" :searchForm="searchForm"
            :page-size="pageSize" :page-sizes="pageSizes" :table-loading="loading" :table-height="tableHeight"
            :is-show-select="true" :page-show="true" :handle-show="false" :merge-flag="false"
            @setSearchHeight="setSearchHeight">
        </com-table>
        <el-dialog :title="titleName" :visible="showAuditDialog" @close="showAuditDialog = false"
            custom-class="alarm-type-detail el-dialog-widthSmall" :close-on-click-modal="false"
            @closed="auditDialogClosed" v-dialogDrag>
            <div class="dengshus">
                <el-form label-width="100px" :model="formInline">
                    <div class="awas">
                        <el-form-item label="策略名称：">
                            <el-input v-model="formInline.KeyType" placeholder="请输入名称"></el-input>
                        </el-form-item>
                    </div>
                    <div class="awas">
                        <el-form-item label="状态：">
                            <el-switch v-model="formInline.status" active-color="#13ce66" inactive-color="#ff4949">
                            </el-switch>
                        </el-form-item>
                    </div>
                    <div class="awas">
                        <el-form-item label="执行对象：">
                            <el-select v-model="formInline.value" placeholder="请选择" style="width:100%;">
                                <el-option v-for="item in options" :key="item.value" :label="item.label"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </div>
                    <div class="awas">
                        <el-form-item label="策略内容：">

                        </el-form-item>
                    </div>
                    <el-table :data="tableData" style="width: 90%; margin-left: 10%;">
                        <el-table-column type="index" label="序号" width="50">
                        </el-table-column>
                        <el-table-column prop="date" label="类型" >
                        </el-table-column>
                        <el-table-column prop="name" label="只读" >
                            <template slot-scope="s">
                                    <el-radio v-model="s.row.label" label="1"> 只读 </el-radio>
                            </template>
                        </el-table-column>
                       <el-table-column prop="name" label="读写" >
                            <template slot-scope="s">
                                    <el-radio v-model="s.row.label" label="2"> 读写 </el-radio>
                            </template>
                        </el-table-column>
                        <el-table-column prop="name" label="禁用" >
                            <template slot-scope="s">
                                    <el-radio v-model="s.row.label" label="3">禁用  </el-radio>
                            </template>
                        </el-table-column>
                        <el-table-column prop="name" label="启用" >
                            <template slot-scope="s">
                                    <el-radio v-model="s.row.label" label="4">  启用</el-radio>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-form>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="showAuditDialog = false">取 消</el-button>
                <el-button type="primary" @click="confirmInfo">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>
<script>
import ComTable from "../../components/table/comTable";
export default {
    name: 'systemLog',
    data() {
        return {
            formInline: {

            },
            titleName:'',
            options: [{
                value: '选项1',
                label: '默认策略对象'
            }, ],
            showAuditDialog: false,
            pageSizes: [5, 10, 20, 50, 100],
            tableHeadList: [],
            formColumns: [],
            pageNum: 1,
            pageSize: 10,
            totalCount: 0,
            hasData: false,
            tableData: [], // 表格数据
            tableHeight: '', // 表格高度
            loading: false, // 数据加载状态遮罩
            tableDataSelected: [],
            searchForm: {
                name: []
            },
            startTime: '',
            endTime: '',
            // tableData: [{
            //     date: '2016-05-02',
            //     name: '王小虎',
            //     label:"1",
            // }, {
            //     date: '2016-05-04',
            //     name: '王小虎',
            //     label:"2",
            // }, ],
        };
    },
    components: {
        ComTable,
    },
    created() {
        this.setTableHeight();
        this.tableHeadList = [
            { colDisabled: false, colHidden: true, colSearch: true, colSort: false, columnComment: "策略名称", columnName: "id" },
            { colDisabled: false, colHidden: false, colSearch: true, colSort: false, columnComment: "执行对象", columnName: "name" },
            { colDisabled: false, colHidden: false, colSearch: true, colSort: false, columnComment: "启用状态", columnName: "ip" },
            { colDisabled: false, colHidden: false, colSearch: true, colSort: false, columnComment: "开启时间", columnName: "desc" },
            { colDisabled: false, colHidden: false, colSearch: true, colSort: false, columnComment: "修改时间", columnName: "ip" },
            { colDisabled: false, colHidden: false, colSearch: true, colSort: false, columnComment: "创建者", columnName: "desc" },

        ];

    },
    methods: {
        auditDialogClosed() {
            this.formInline = {}
            this.showAuditDialog = false
        },
        increase(val) {
            if(val==='add'){
                this.titleName='新增'
            }else{
                this.titleName='修改'
            }
            this.showAuditDialog = true
        },
        confirmInfo() {
            this.auditDialogClosed()
            this.$message({
                type: 'success',
                message: '新增成功!'
            });
        },
        //加载表格
        setSearchHeight() {
            //搜索区域高度
            if (this.$refs.search !== undefined) {
                this.$nextTick(() => {
                    let searchHeight = this.$refs.search.offsetHeight;
                    this.setTableHeight(searchHeight);
                });
            }
        },
        addDelet() {
            this.$confirm('此操作将永久删除, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$message({
                    type: 'success',
                    message: '删除成功!'
                });
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消删除'
                });
            });
        },
        /**
         * 设置表格的高度
         */
        setTableHeight() {
            let clientHeiht = window.innerHeight || document.documentElement.clientHeight;
            this.tableHeight = clientHeiht - 280;
        },
        //查询
        search(val) {
            if (val == true) {
                this.showImportDialog = false;
                this.$refs.comTable.getTableData(this.pageNum, this.pageSize, this.searchForm);
            }
        },
        //重置
        clearData() {
            this.searchForm = {}
            this.search()
        }
    }
}
</script>
<style scoped>
</style>
